package com.jiedeng.dao;

import com.jiedeng.model.CheckCount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author 覃远龙
 * @ClassName: ICheckCountRepository
 * @Description:
 * @date 2017/8/4 11:16
 */
public interface ICheckCountRepository extends JpaRepository<CheckCount, String> {

    List<CheckCount> findByCheckId(String checkId);

    List<CheckCount> findByCheckIdAndPostId(String checkId, long postId);
    List<CheckCount> findByCheckIdAndCorpWeightLevel(String checkId, String corpWeightLevel);
    List<CheckCount> findByCheckIdAndCorpIdAndPostIdAndPersonIdAndCorpWeightLevel(String checkId, long corpId, long postId, long personId,String corpWeightLevel);
    @Modifying
    @Transactional
    void deleteByCheckId(String checkId);


    @Query(nativeQuery = true, value = "select count(1)  from t_check tc LEFT JOIN t_checkcount tcc on tcc.Check_ID=tc.ID where tcc.ID is null  and  tc.Task_ID = ?1 and  tc.isColse_File = 1")
    int selectNotCheckCountNum(String tackId);
}
